#[cfg(test)]
mod tests {
    #[test]
    fn macro_include_bytes() {
        let bytes = include_bytes!("spanish.in");
        // assert_eq!(bytes, b"adi\xc3\xb3s\n");
        println!("{}", String::from_utf8_lossy(bytes));

        let my_str = include_str!("spanish.in");
        assert_eq!(my_str, "adiós");
        print!("{my_str}");
    }

    #[test]
    fn test_macro_log_syntax() {
        log::info!("test_macro_log_syntax");
        println!("test_macro_log_syntax");
    }

    #[test]
    fn test_macro_match() {
        let foo = 'f';
        assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));
        println!("{}", matches!(foo, 'A'..='Z' | 'a'..='z'));

        let bar = Some(4);
        assert!(matches!(bar, Some(x) if x > 2));
        println!("{}", matches!(bar, Some(x) if x < 2));
    }

    #[test]
    fn test_macro_option_env() {
        let key: Option<&'static str> = option_env!("SECRET_KEY");
        println!("the secret key might be: {key:?}");
        let key2: Option<&'static str> = option_env!("PATH");
        println!("the secret key might be: {key2:?}");
    }

    #[test]
    fn test_macro_thread_local() {
        use std::cell::RefCell;
        thread_local! {
            pub static FOO1: RefCell<u32> = RefCell::new(1);

            static BAR: RefCell<f32> = RefCell::new(1.0);
        }

        FOO1.with(|foo| assert_eq!(*foo.borrow(), 1));
        BAR.with(|bar| assert_eq!(*bar.borrow(), 1.0));

        use std::cell::Cell;
        thread_local! {
            pub static FOO: Cell<u32> = const { Cell::new(1) };
        }

        FOO.with(|foo| assert_eq!(foo.get(), 1));
    }

    #[test]
    fn test_macro_unreachable() {
        // unreachable!();
        #[allow(dead_code)]
        fn foo(x: Option<i32>) {
            match x {
                Some(n) if n >= 0 => println!("Some(Non-negative)"),
                Some(n) if n < 0 => println!("Some(Negative)"),
                Some(_) => unreachable!(), // 如果注释掉，就会编译错误
                None => println!("None"),
            }
        }

        foo(Some(1));
    }
}
